// 获取json5中模拟数据
import res from '../../../../../data/onlineMonitorCfg.json';
import resCurve from '../../../../../data/curveChartCfg.json';

export default {
  namespace: 'onlineMonitor',
  state: {
    sc: [],
    ecgsbf: [],
    lljcd: [],
    szjcd: [],
    yljcd: [],
    loading: false,
    scCurve: [],
    ecgsbfCurve: [],
    lljcdCurve: [],
    szjcdCurve: [],
    yljcdCurve: [],
    loadingCurve: false,
    projectMapData: {} // 工程点位信息
  },

  effects: {
    *fetchData({ payload }, { call, put }) {
      const { data: { sc, ecgsbf, lljcd, szjcd, yljcd } } = res;
      const { data: { scCurve, ecgsbfCurve, lljcdCurve, szjcdCurve, yljcdCurve } } = resCurve;
      yield put({
        type: 'saveState',
        payload: {
          sc,
          ecgsbf,
          lljcd,
          szjcd,
          yljcd,
          loading: true,
          scCurve,
          ecgsbfCurve,
          lljcdCurve,
          szjcdCurve,
          yljcdCurve,
          loadingCurve: true
        }
      })
    },
  },
  reducers: {
    saveState(state, { payload }) {
      return { ...state, ...payload };
    }
  },
};
